
class Solution
{
public:
    bool canConstruct(string ransomNote, string magazine)
    {
        int magCount[26] = {0};
        for (int i = 0; i < magazine.size(); ++i)
        {
            magCount[magazine[i] - 'a'] += 1;
        }
        for (int i = 0; i < ransomNote.size(); ++i)
        {
            magCount[ransomNote[i] - 'a'] -= 1;
            if (magCount[ransomNote[i] - 'a'] < 0)
            {
                return false;
            }
        }
        return true;
    }
};